<?php
namespace app\cms\model;
/* *
 * 自定义单页功能
 * */
class diypage extends \app\base\model\AdminModel{
    protected $table ='cms_diypage';  //模型表

    //列表
    public function _select($website_id){
        if($website_id){
            $condition['website_id'] = $website_id;
        }else{
            $condition = array();
        }
        return $this->table('cms_diypage as A')
            ->join('{pre}website as B ON A.website_id = B.id')
            ->field('A.*,B.title as website_name')
            ->where($condition)
            ->order('a.id desc')
            ->select();
    }

    //单个
    public function _find($condition){
        return $this->where($condition)->find();
    }

    //删除
    public function _delete($condition){
        return $this->where($condition)->delete();
    }  

    //编辑
    public function _update($data,$condition = NULL){
        if($condition){
            return $this->where($condition)->data($data)->update();
        }else{
            return $this->data($data)->insert();
        }
    } 
}